package com.chejianer.phone.utils;

import sun.misc.BASE64Encoder;

import java.io.UnsupportedEncodingException;
import java.security.SecureRandom;
import java.util.Random;

/**
 * 实现创建16位的随机字符串的方法
 * Created by Chejianer on 2016/8/25.
 */
public class CreateNonce {
    private static SecureRandom secureRandom=new SecureRandom();
    public static String getNonce(){
        byte[] bytes=new byte[12];
        secureRandom.nextBytes(bytes);
        String nonce=new BASE64Encoder().encode(bytes);
        System.out.println(nonce);
        return nonce;
    }
}
